package com.ruoyi.buss.qmcy.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.buss.utils.DateUtilss;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.buss.qmcy.mapper.QmcyCustCkjgMapper;
import com.ruoyi.buss.qmcy.domain.QmcyCustCkjg;
import com.ruoyi.buss.qmcy.service.IQmcyCustCkjgService;

/**
 * 存款结构Service业务层处理
 * 
 * @author sxy
 * @date 2021-07-16
 */
@Service
public class QmcyCustCkjgServiceImpl implements IQmcyCustCkjgService 
{
    @Autowired
    private QmcyCustCkjgMapper qmcyCustCkjgMapper;

    /**
     * 查询存款结构
     * 
     * @param ckye 存款结构ID
     * @return 存款结构
     */
    @Override
    public QmcyCustCkjg selectQmcyCustCkjgById(String ckye)
    {
        return qmcyCustCkjgMapper.selectQmcyCustCkjgById(ckye);
    }

    /**
     * 查询存款结构列表
     * 
     * @param qmcyCustCkjg 存款结构
     * @return 存款结构
     */
    @Override
    public List<QmcyCustCkjg> selectQmcyCustCkjgList(QmcyCustCkjg qmcyCustCkjg, LoginUser userInfo)
    {
        List<QmcyCustCkjg> doList = new ArrayList<QmcyCustCkjg>();

        /**
         * 判断数据日期是否为近3年4个季度以及当年每个月月末
         */
        ArrayList<String> sjrqs = DateUtilss.getThreeYearFourQuarterAndMonth();
        if (!StringUtils.isEmpty(qmcyCustCkjg.getSjrq())) {
            if ("9999".equals(qmcyCustCkjg.getSjrq())) {
                qmcyCustCkjg.setSjrq("");
            }
            sjrqs = new ArrayList<String>();
            String sjrq = qmcyCustCkjg.getSjrq();
            sjrq = sjrq.replace("-", "");
            sjrqs.add(sjrq);
        }
        qmcyCustCkjg.setSjrqs(sjrqs);
        doList = qmcyCustCkjgMapper.ckjg(qmcyCustCkjg);

        return doList;
    }

    /**
     * 新增存款结构
     * 
     * @param qmcyCustCkjg 存款结构
     * @return 结果
     */
    @Override
    public int insertQmcyCustCkjg(QmcyCustCkjg qmcyCustCkjg)
    {
        return qmcyCustCkjgMapper.insertQmcyCustCkjg(qmcyCustCkjg);
    }

    /**
     * 修改存款结构
     * 
     * @param qmcyCustCkjg 存款结构
     * @return 结果
     */
    @Override
    public int updateQmcyCustCkjg(QmcyCustCkjg qmcyCustCkjg)
    {
        return qmcyCustCkjgMapper.updateQmcyCustCkjg(qmcyCustCkjg);
    }

    /**
     * 批量删除存款结构
     * 
     * @param ckyes 需要删除的存款结构ID
     * @return 结果
     */
    @Override
    public int deleteQmcyCustCkjgByIds(String[] ckyes)
    {
        return qmcyCustCkjgMapper.deleteQmcyCustCkjgByIds(ckyes);
    }

    /**
     * 删除存款结构信息
     * 
     * @param ckye 存款结构ID
     * @return 结果
     */
    @Override
    public int deleteQmcyCustCkjgById(String ckye)
    {
        return qmcyCustCkjgMapper.deleteQmcyCustCkjgById(ckye);
    }
}
